package com.ruoyi.wcf.controller;

import java.util.List;

import com.ruoyi.mall.domain.MallTimeWarehouse;
import com.ruoyi.wcf.domain.WcfClassManage;
import com.ruoyi.wcf.service.IWcfClassManageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfRecommendProduct;
import com.ruoyi.wcf.service.IWcfRecommendProductService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推荐产品管理Controller
 *
 * @author LCL
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/wcf/WcfRecommendProduct")
public class WcfRecommendProductController extends BaseController
{
    @Autowired
    private IWcfRecommendProductService wcfRecommendProductService;
    @Autowired
    private IWcfClassManageService wcfClassManageService;

    /**
     * 查询推荐产品管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfRecommendProduct wcfRecommendProduct)
    {
        startPage();
        List<WcfRecommendProduct> list = wcfRecommendProductService.selectWcfRecommendProductList(wcfRecommendProduct);
        return getDataTable(list);
    }

    /**
     * 导出推荐产品管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:export')")
    @Log(title = "推荐产品管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfRecommendProduct wcfRecommendProduct)
    {
        List<WcfRecommendProduct> list = wcfRecommendProductService.selectWcfRecommendProductList(wcfRecommendProduct);
        ExcelUtil<WcfRecommendProduct> util = new ExcelUtil<WcfRecommendProduct>(WcfRecommendProduct.class);
        return util.exportExcel(list, "推荐产品管理数据");
    }

    /**
     * 获取推荐产品管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:query')")
    @GetMapping(value = "/{recommendId}")
    public AjaxResult getInfo(@PathVariable("recommendId") Long recommendId)
    {
        return AjaxResult.success(wcfRecommendProductService.selectWcfRecommendProductByRecommendId(recommendId));
    }

    /**
     * 新增推荐产品管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:add')")
    @Log(title = "推荐产品管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfRecommendProduct wcfRecommendProduct)
    {
        return toAjax(wcfRecommendProductService.insertWcfRecommendProduct(wcfRecommendProduct));
    }

    /**
     * 修改推荐产品管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:edit')")
    @Log(title = "推荐产品管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfRecommendProduct wcfRecommendProduct)
    {
        return toAjax(wcfRecommendProductService.updateWcfRecommendProduct(wcfRecommendProduct));
    }

    /**
     * 删除推荐产品管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRecommendProduct:remove')")
    @Log(title = "推荐产品管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recommendIds}")
    public AjaxResult remove(@PathVariable Long[] recommendIds)
    {
        return toAjax(wcfRecommendProductService.deleteWcfRecommendProductByRecommendIds(recommendIds));
    }

    /**
     * 查询分类管理
     */
    @GetMapping("/getClassManageList")
    public AjaxResult getClassManageList(WcfClassManage wcfClassManage)
    {
        List<WcfClassManage> list = wcfClassManageService.selectWcfClassManageList(wcfClassManage);
        return AjaxResult.success(list);
    }
}
